package typeErasure;

public class Generator2<T extends Number> {

    private T key;

    public Generator2(T key) {
        this.key = key;
    }

    public T getKey() {
        return this.key;
    }

    // 编译错误 Unexpected bound
//    public <T> showKeyName(Generator2<T extends Number> generator2 ) {}

    // 泛型方法添加上下边界的时，必须在权限声明与返回值之间<T>上添加上下边界，即在泛型生咪咕的时候添加
    public <T extends Number> T showKeyName(Generator2<T> generator2) {
        System.out.println("key is:" + generator2.key);
        T test = generator2.key;
        return test;
    }

    public static void main(String[] args) {
        // String 不是Number的子类
//        Generator2<String> generator2 = new Generator2();



    }

}
